package com.lua.event;

import com.googlecode.protobuf.format.JsonFormat;
import com.helper.ProtoJson;
import com.nioserver.propertys.Role;
import com.nioserver.propertys.RoleMaps;
import com.proto.TMessage;
import net.sf.json.JSONObject;

public class callClient extends JSONEvent {
    @Override
    public String op(String jb) {
        JSONObject jsonObject = JSONObject.fromObject(jb);
        int address = jsonObject.getInt("address");
        try {
            TMessage.Words words = ProtoJson.Json2Words(jsonObject.getString("params"));
            Role rl = RoleMaps.getRole(address);
            rl.socket.writeAsync(words);
        } catch (JsonFormat.ParseException e) {
            e.printStackTrace();
        }

        return "success";
    }
}
